package cn.enilu.flash.enums.body;

import cn.enilu.flash.enums.OptionObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author Spark
 * @Date Created in (2019/10/31 15:02)
 * @Version v1.0
 * @Modify
 **/
public enum ProvinceShortName implements OptionObject {

    JI_LIN(0, "吉"),
    HEI_LONG_JIANG(1, "黑"),
    LIAO_NING(2, "辽"),
    HE_BEI(3,"冀"),
    SHAN_DONG(4,"鲁"),
    HE_NAN(5,"豫"),
    BEI_JING(6,"京"),
    TIAN_JIN(7,"津"),
    CHONG_QING(8,"渝"),
    SHANG_HAI(9,"沪"),
    YUN_NAN(10,"云"),
    HU_NAN(11,"湘"),
    AN_HUI(12,"皖"),
    XIN_JIANG(13,"新"),
    JIANG_SU(14,"苏"),
    ZHE_JIANG(15,"浙"),
    JIANG_XI(16,"赣"),
    HU_BEI(17,"鄂"),
    GUANG_XI(18,"桂"),
    GAN_SU(19,"甘"),
    SHAN_XI(20,"晋"),
    NEI_MENG_GU(21,"蒙"),
    SHAN_XI1(22,"陕"),
    FU_JIAN(23,"闽"),
    GUI_ZHOU(24,"贵"),
    GUANG_DONG(25,"粤"),
    QING_HAI(26,"青"),
    SI_CHUAN(27,"川"),
    NING_XIA(28,"宁"),
    HAI_NAN(29,"琼")
    ;

    private int code;
    private String text;


    ProvinceShortName(int code, String text){
        this.code = code;
        this.text = text;
    }

    public static Map<Integer, String> toMap = new HashMap<Integer, String>();

    static {
        ProvinceShortName[] types = ProvinceShortName.values();
        for (ProvinceShortName type : types) {
            toMap.put(type.getCode(), type.getText());
        }
    }

    public static String valueOfCode(int code) {
        ProvinceShortName[] bts = ProvinceShortName.values();
        for (ProvinceShortName bt : bts) {
            if(bt.getCode() == code){
                return bt.getText();
            }
        }
        return "--";
    }

    @Override
    public int getCode() {
        return this.code;
    }

    @Override
    public String getText() {
        return this.text;
    }

    @Override
    public boolean compare(int code){
        if(this.getCode() == code){
            return true;
        }
        return false;
    }
}
